<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>iNote | Admin</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <meta name="renderer" content="webkit">
    <link rel="shortcut icon" href="/static/css/inote_fav.ico">
    <!-- Bootstrap 3.3.2 -->
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <!-- Font Awesome Icons -->
    <link href="/static/freelancer/font-awesome/css/font-awesome.min.css" rel="stylesheet"
          type="text/css"/>
    <!-- Ionicons -->
    <link href="/static/css/ionicons.min.css" rel="stylesheet" type="text/css"/>
    <!-- Theme style -->
    <link href="/static/dist/css/AdminLTE.min.css" rel="stylesheet" type="text/css"/>
    <!-- AdminLTE Skins. Choose a skin from the css/skins 
         folder instead of downloading all of them to reduce the load. -->
    <!--<link rel="stylesheet" href="/static/dist/css/skins/_all-skins.min.css"/>-->
    <link rel="stylesheet" href="/static/dist/css/skins/skin-blue.min.css"/>
    <link rel="stylesheet" href="/static/plugins/editormd/css/editormd.css"/>
    <link rel="stylesheet" href="/static/css/inote.css"/>

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="/static/js/html5shiv.js"></script>
    <script src="/static/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue">
<!-- Site wrapper -->
<div class="wrapper">

    <header class="main-header">
        <a href="/admin/main" class="logo">iNote后台管理</a>
        <!-- Header Navbar: style can be found in header.less -->
        <nav class="navbar navbar-static-top" role="navigation">
            <!-- Sidebar toggle button-->
            <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </a>

            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">
                    <!-- Messages: style can be found in dropdown.less-->
                    <li>
                        <a href="/" target="_blank" title="iNote首页">
                            <i class="glyphicon glyphicon-home"></i>
                        </a>
                    </li>
                    <!-- User Account: style can be found in dropdown.less -->
                    <li class="dropdown user user-menu">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <img id="avatar" src="" class="user-image" alt="User Image"/>
                            <span id="author" class="hidden-xs"></span>
                        </a>
                        <ul class="dropdown-menu">
                            <!-- Menu Footer-->
                            <li class="user-footer">
                                <div class="pull-left">
                                    <a href="#" class="btn btn-default btn-flat" data-toggle="modal" data-target="#resetPwdModel">重置密码</a>
                                </div>
                                <div class="pull-right">
                                    <a href="#" id="btnLogout" class="btn btn-default btn-flat">退出</a>
                                </div>
                            </li>
                        </ul>
                    </li>
                </ul>
            </div>
        </nav>
    </header>

    <!-- Left side column. contains the sidebar -->
    <aside class="main-sidebar">
        <!-- sidebar: style can be found in sidebar.less -->
        <section class="sidebar">
            <!-- sidebar menu: : style can be found in sidebar.less -->
            <ul class="sidebar-menu">
                <li class="header">功能管理</li>
                <li><a href="#" class="menu-page" data-page="/admin/user"><i class="glyphicon glyphicon-user text-danger"></i>用户信息管理</a></li>
                <li><a href="#" class="menu-page"  data-page="/admin/post"><i class="glyphicon glyphicon-file text-info"></i>内容管理</a></li>
                <li><a href="#" class="menu-page"  data-page="/admin/message"><i class="glyphicon glyphicon-inbox text-info"></i>留言管理</a></li>
            </ul>
        </section>
        <!-- /.sidebar -->
    </aside>

    <!-- Right side column. Contains the navbar and content of the page -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <div id="content">
                <h2 class="lead text-center text-blue text-bold">欢迎使用iNote</h2>
                <hr class="divider"/>
                <p id="aboutMeMain" class="text-center"></p>
                <p class="text-center"><a href="https://github.com/igordonshaw/inote" target="_blank"><i class="fa fa-github">&nbsp;&nbsp;fork me on github</i></a></p>
            </div>
        </section>

    </div>
    <!-- /.content-wrapper -->
</div>
<!-- ./wrapper -->
<!-- reset pwd -->
<div class="modal fade" id="resetPwdModel" tabindex="-1" role="dialog" aria-labelledby="resetPwdModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="resetPwdModalLabel">重置密码</h4>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <div>
                        <label for="newPwd">新密码</label>
                        <input type="password" class="form-control" id="newPwd"/>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="resetPwdBtn">确定</button>
            </div>
        </div>
    </div>
</div>

<!-- jQuery -->
<script src="/static/plugins/jQuery/jQuery-2.1.3.min.js"></script>
<!-- Bootstrap 3.3.2 JS -->
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="/static/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src='/static/plugins/fastclick/fastclick.min.js'></script>
<!-- AdminLTE App -->
<script src="/static/js/jquery.form.min.js"></script>
<script src="/static/js/json2-min.js"></script>
<script src="/static/js/jquery.md5.js"></script>
<script src="/static/plugins/editormd/editormd.min.js"></script>
<script src="/static/plugins/highlight/js/highlight.min.js"></script>
<script src="/static/dist/js/app.min.js"></script>
<script src="/static/js/util.js"></script>
<script>
    $(function(){
        // 获取用户信息
        $.get('/author', function(user){
            $('#avatar').attr('src', user.thumb);
            $('#author').text(user.userName);
            $('#aboutMeMain').text(user.aboutMe);
        });
        // 加载菜单页面
        $('.sidebar-menu .menu-page').on('click', function(){
            $('#content').load($(this).attr('data-page'));
            $(this).parent().addClass('active').siblings().removeClass('active');
        });

        // 重置密码
        $('#resetPwdBtn').on('click', function(){
           var newPwd = $('#newPwd').val();
            if($.trim(newPwd) == ""){
                alert("新密码不能为空");
                return false;
            }
            $.ajax({
                type: 'POST',
                url: '/admin/resetPwd',
                data: $.md5(newPwd),
                contentType: 'applcation/json',
                success: function(res){
                    if(res.success){
                        alert(res.msg);
                        $('#newPwd').val('');
                        $('#resetPwdModel').modal('hide');
                    }
                }
            });
        });
        // 退出登录
        $('#btnLogout').on('click', function(){
            $.get('/admin/logout', function(res){
                window.location = "/";
            });
        });
    });
</script>
</body>
</html>